import java.util.Scanner;

public class StringDemo9 {
    public static void main(String[] args) {
        //1.键盘录入金额
        Scanner sc = new Scanner(System.in);
        int money;
        while (true) {
            System.out.println("请输入金额");
            money = sc.nextInt();
            if (money >= 0 && money <= 99999999) {
                break;
            } else {
                System.out.println("金额错误");
            }
        }
        String moneyStr = "";
        //得到money里的每一个数字
        while (true) {
            //获取个位
            int ge = money % 10;
            String capitalNumber = getCapitalNumber(ge);//2135
            moneyStr = capitalNumber + moneyStr;
            //第一次循环"伍"+""
            //第二次循环"叁"+"伍"
            //去掉刚刚获取的数据
            money = money / 10;
            if (money == 0) {
                break;
            }
        }
        int count = 7 - moneyStr.length();
        for (int i = 0; i < count; i++) {
            moneyStr = "零" + moneyStr;
        }
        System.out.println(moneyStr);
        //4.插入单位
        String result = "";
        String[] arr = {"佰", "拾", "万", "仟", "佰", "拾", "元"};
        for (int i = 0; i < moneyStr.length(); i++) {
            char c = moneyStr.charAt(i);
            result = result + c + arr[i];
        }
        System.out.println(result);
    }

    public static String getCapitalNumber(int number) {
        String[] arr = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
        return arr[number];
    }
}
